decide.nolog.cz/tests/integration/mirage-test.js
2023-11-04 17:32:09 +01:00

38 lines
1,005 B
JavaScript

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import sjcl from 'sjcl';
module('Integration | Mirage api mocking', function (hooks) {
setupTest(hooks);
setupMirage(hooks);
test('poll factory | encrypts properties', function (assert) {
let encryptionKey = 'abc';
let poll = this.server.create('poll', {
description: 'bar',
encryptionKey,
title: 'foo',
});
assert.strictEqual(
JSON.parse(sjcl.decrypt(encryptionKey, poll.title)),
'foo',
);
assert.strictEqual(
JSON.parse(sjcl.decrypt(encryptionKey, poll.description)),
'bar',
);
});
test('user factory | encrypts properties', function (assert) {
let encryptionKey = 'abc';
let user = this.server.create('user', {
encryptionKey,
name: 'foo',
});
assert.strictEqual(
JSON.parse(sjcl.decrypt(encryptionKey, user.name)),
'foo',
);
});
});