feat: 🎸 Add storage bucket models (#85)
* feat: 🎸 Add storage bucket models ✅ Closes: ICU-8076
This commit is contained in:
1 parent
c30bc3a554
commit
4d62e67f2a
4 files changed
+226
No files matched your search
@@ -0,0 +1,80 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import { TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3 } from 'api/models/storage-bucket';
|
||||
|
||||
module('Unit | Model | storage bucket', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('storage-bucket', {});
|
||||
assert.ok(model);
|
||||
});
|
||||
|
||||
test('it has the isPlugin property and returns the expected values', async function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const modelPlugin = store.createRecord('storage-bucket', {
|
||||
type: 'plugin',
|
||||
plugin: {
|
||||
name: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
|
||||
},
|
||||
});
|
||||
assert.true(modelPlugin.isPlugin);
|
||||
});
|
||||
|
||||
test('it has isUnknown property and returns the expected values', async function (assert) {
|
||||
assert.expect(2);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const modelA = store.createRecord('storage-bucket', {
|
||||
compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
|
||||
});
|
||||
const modelB = store.createRecord('storage-bucket', {
|
||||
compositeType: 'no-such-type',
|
||||
});
|
||||
assert.false(modelA.isUnknown);
|
||||
assert.true(modelB.isUnknown);
|
||||
});
|
||||
|
||||
test('it has isAWS property and returns the expected values', async function (assert) {
|
||||
assert.expect(2);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const modelAws = store.createRecord('storage-bucket', {
|
||||
type: 'plugin',
|
||||
plugin: { name: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3 },
|
||||
});
|
||||
const modelRandom = store.createRecord('storage-bucket', {
|
||||
plugin: { name: 'random' },
|
||||
});
|
||||
assert.true(modelAws.isAWS);
|
||||
assert.false(modelRandom.isAWS);
|
||||
});
|
||||
|
||||
test('get compositeType returns expected values', async function (assert) {
|
||||
assert.expect(2);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const modelA = store.createRecord('storage-bucket', {
|
||||
type: 'plugin',
|
||||
plugin: { name: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3 },
|
||||
});
|
||||
const modelB = store.createRecord('storage-bucket', {
|
||||
type: 'plugin',
|
||||
plugin: { name: 'no-such-type' },
|
||||
});
|
||||
assert.strictEqual(modelA.compositeType, TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3);
|
||||
assert.strictEqual(modelB.compositeType, 'unknown');
|
||||
});
|
||||
|
||||
test('set compositeType sets expected values', async function (assert) {
|
||||
assert.expect(2);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const modelPlugin = store.createRecord('storage-bucket', {
|
||||
compositeType: TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3,
|
||||
});
|
||||
assert.strictEqual(modelPlugin.type, 'plugin');
|
||||
assert.strictEqual(
|
||||
modelPlugin.plugin.name,
|
||||
TYPE_STORAGE_BUCKET_PLUGIN_AWS_S3
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user