Move tests
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { module, test } from 'ember-qunit';
|
||||
import schemas from 'npm:kosmos-schemas';
|
||||
import tv4 from 'npm:tv4';
|
||||
import { ContributionSerializer } from 'kredits-web/lib/kredits';
|
||||
|
||||
module('Serializers contribution');
|
||||
|
||||
test('#serialize returns a valid JSON-LD representation', function(assert) {
|
||||
let serialized = ContributionSerializer.serialize({
|
||||
recipientAddress: '0xd4a64570b12da659ee4bbd41c3509b7b1f9c51ac',
|
||||
kind: 'design',
|
||||
description: 'New logo design',
|
||||
url: 'http://opensourcedesign.org',
|
||||
contributorIpfsHash: 'QmT2A7rY4e7uoKktkcFHQNN7BD1oXdZTgd8wNkr1u9nNVE'
|
||||
});
|
||||
|
||||
let valid = tv4.validate(JSON.parse(serialized), schemas['contribution']);
|
||||
assert.ok(valid);
|
||||
});
|
||||
|
||||
test('#deserialize returns a valid object representation', function(assert) {
|
||||
let json = JSON.stringify({
|
||||
"@context": "https://schema.kosmos.org",
|
||||
"@type": "Contribution",
|
||||
"contributor": {
|
||||
"ipfs": "QmT2A7rY4e7uoKktkcFHQNN7BD1oXdZTgd8wNkr1u9nNVE"
|
||||
},
|
||||
"kind": "design",
|
||||
"description": "New logo design",
|
||||
"details": {},
|
||||
"url": "http://opensourcedesign.org"
|
||||
});
|
||||
let deserialized = ContributionSerializer.deserialize(json);
|
||||
|
||||
let expected = {
|
||||
kind: 'design',
|
||||
description: 'New logo design',
|
||||
details: {},
|
||||
url: 'http://opensourcedesign.org',
|
||||
ipfsData: json,
|
||||
};
|
||||
assert.deepEqual(expected, deserialized);
|
||||
});
|
||||
Reference in New Issue
Block a user