Update Ember to 3.1
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
moduleFor('controller:application', 'Unit | Controller | application', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
module('Unit | Controller | application', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.subject();
|
||||
assert.ok(controller);
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.owner.lookup('controller:application');
|
||||
assert.ok(controller);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,33 +1,29 @@
|
||||
import Ember from 'ember';
|
||||
import { isEmpty, isPresent } from '@ember/utils';
|
||||
import Contributor from 'kredits-web/models/contributor';
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
const {
|
||||
isPresent,
|
||||
isEmpty
|
||||
} = Ember;
|
||||
module('Unit | Controller | index', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
moduleFor('controller:index', 'Unit | Controller | index', {
|
||||
needs: ['service:kredits']
|
||||
});
|
||||
let addFixtures = function(controller) {
|
||||
[
|
||||
{ github_username: "neo", github_uid: "318", balance: 10000 },
|
||||
{ github_username: "morpheus", github_uid: "843", balance: 15000 },
|
||||
{ github_username: "trinity", github_uid: "123", balance: 5000 },
|
||||
{ github_username: "mouse", github_uid: "696", balance: 0 }
|
||||
].forEach(fixture => {
|
||||
controller.get('kredits.contributors').push(Contributor.create(fixture));
|
||||
});
|
||||
};
|
||||
|
||||
let addFixtures = function(controller) {
|
||||
[
|
||||
{ github_username: "neo", github_uid: "318", balance: 10000 },
|
||||
{ github_username: "morpheus", github_uid: "843", balance: 15000 },
|
||||
{ github_username: "trinity", github_uid: "123", balance: 5000 },
|
||||
{ github_username: "mouse", github_uid: "696", balance: 0 }
|
||||
].forEach(fixture => {
|
||||
controller.get('kredits.contributors').push(Contributor.create(fixture));
|
||||
test('doesn\'t contain people with 0 balance', function(assert) {
|
||||
let controller = this.owner.lookup('controller:index');
|
||||
addFixtures(controller);
|
||||
|
||||
let contributorsSorted = controller.get('contributorsSorted');
|
||||
|
||||
assert.ok(isPresent(contributorsSorted.findBy('github_username', 'neo')));
|
||||
assert.ok(isEmpty(contributorsSorted.findBy('github_username', 'mouse')));
|
||||
});
|
||||
};
|
||||
|
||||
test('doesn\'t contain people with 0 balance', function(assert) {
|
||||
let controller = this.subject();
|
||||
addFixtures(controller);
|
||||
|
||||
let contributorsSorted = controller.get('contributorsSorted');
|
||||
|
||||
assert.ok(isPresent(contributorsSorted.findBy('github_username', 'neo')));
|
||||
assert.ok(isEmpty(contributorsSorted.findBy('github_username', 'mouse')));
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
moduleFor('controller:proposals/new', 'Unit | Controller | proposals/new', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
module('Unit | Controller | proposals/new', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.subject();
|
||||
assert.ok(controller);
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.owner.lookup('controller:proposals/new');
|
||||
assert.ok(controller);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
import { module, test } from 'ember-qunit';
|
||||
import { module, test } from 'qunit';
|
||||
import schemas from 'npm:kosmos-schemas';
|
||||
import tv4 from 'npm:tv4';
|
||||
import ContributionSerializer from 'kredits-web/lib/kredits/serializers/contribution';
|
||||
|
||||
module('Serializers contribution');
|
||||
module('Serializers contribution', function() {
|
||||
test('#serialize returns a valid JSON-LD representation', function(assert) {
|
||||
let serialized = ContributionSerializer.serialize({
|
||||
kind: 'design',
|
||||
description: 'New logo design',
|
||||
url: 'http://opensourcedesign.org',
|
||||
contributorIpfsHash: 'QmT2A7rY4e7uoKktkcFHQNN7BD1oXdZTgd8wNkr1u9nNVE'
|
||||
});
|
||||
|
||||
test('#serialize returns a valid JSON-LD representation', function(assert) {
|
||||
let serialized = ContributionSerializer.serialize({
|
||||
kind: 'design',
|
||||
description: 'New logo design',
|
||||
url: 'http://opensourcedesign.org',
|
||||
contributorIpfsHash: 'QmT2A7rY4e7uoKktkcFHQNN7BD1oXdZTgd8wNkr1u9nNVE'
|
||||
let valid = tv4.validate(JSON.parse(serialized), schemas['contribution']);
|
||||
assert.ok(valid);
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
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 expected = {
|
||||
kind: 'design',
|
||||
description: 'New logo design',
|
||||
details: {},
|
||||
url: 'http://opensourcedesign.org',
|
||||
ipfsData: json,
|
||||
};
|
||||
assert.deepEqual(expected, deserialized);
|
||||
});
|
||||
let deserialized = ContributionSerializer.deserialize(json);
|
||||
|
||||
let expected = {
|
||||
kind: 'design',
|
||||
description: 'New logo design',
|
||||
details: {},
|
||||
url: 'http://opensourcedesign.org',
|
||||
ipfsData: json,
|
||||
};
|
||||
assert.deepEqual(expected, deserialized);
|
||||
});
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
import { module, test } from 'ember-qunit';
|
||||
import { module, test } from 'qunit';
|
||||
import schemas from 'npm:kosmos-schemas';
|
||||
import tv4 from 'npm:tv4';
|
||||
import ContributorSerializer from 'kredits-web/lib/kredits/serializers/contributor';
|
||||
|
||||
module('Serializers contributor');
|
||||
module('Serializers contributor', function() {
|
||||
test('#serialize returns a valid JSON-LD representation', function(assert) {
|
||||
let serialized = ContributorSerializer.serialize({
|
||||
name: 'Satoshi Nakamoto',
|
||||
kind: 'person',
|
||||
github_uid: 123,
|
||||
github_username: 'therealsatoshi',
|
||||
wiki_username: 'Satoshi',
|
||||
});
|
||||
|
||||
test('#serialize returns a valid JSON-LD representation', function(assert) {
|
||||
let serialized = ContributorSerializer.serialize({
|
||||
name: 'Satoshi Nakamoto',
|
||||
kind: 'person',
|
||||
github_uid: 123,
|
||||
github_username: 'therealsatoshi',
|
||||
wiki_username: 'Satoshi',
|
||||
let valid = tv4.validate(JSON.parse(serialized), schemas['contributor']);
|
||||
assert.ok(valid);
|
||||
});
|
||||
|
||||
let valid = tv4.validate(JSON.parse(serialized), schemas['contributor']);
|
||||
assert.ok(valid);
|
||||
});
|
||||
test('#deserialize returns a valid object representation', function(assert) {
|
||||
let json = JSON.stringify({
|
||||
"@context": "https://schema.kosmos.org",
|
||||
"@type": "Contributor",
|
||||
"kind": "person",
|
||||
"name": "Satoshi Nakamoto",
|
||||
"accounts": [
|
||||
{
|
||||
"site": "github.com",
|
||||
"uid": 123,
|
||||
"username": "therealsatoshi",
|
||||
"url": "https://github.com/therealsatoshi"
|
||||
},
|
||||
{
|
||||
"site": "wiki.kosmos.org",
|
||||
"username": "Satoshi",
|
||||
"url": "https://wiki.kosmos.org/User:Satoshi"
|
||||
}
|
||||
]
|
||||
});
|
||||
let deserialized = ContributorSerializer.deserialize(json);
|
||||
|
||||
test('#deserialize returns a valid object representation', function(assert) {
|
||||
let json = JSON.stringify({
|
||||
"@context": "https://schema.kosmos.org",
|
||||
"@type": "Contributor",
|
||||
"kind": "person",
|
||||
"name": "Satoshi Nakamoto",
|
||||
"accounts": [
|
||||
{
|
||||
"site": "github.com",
|
||||
"uid": 123,
|
||||
"username": "therealsatoshi",
|
||||
"url": "https://github.com/therealsatoshi"
|
||||
},
|
||||
{
|
||||
"site": "wiki.kosmos.org",
|
||||
"username": "Satoshi",
|
||||
"url": "https://wiki.kosmos.org/User:Satoshi"
|
||||
}
|
||||
]
|
||||
let expected = {
|
||||
name: 'Satoshi Nakamoto',
|
||||
kind: 'person',
|
||||
github_uid: 123,
|
||||
github_username: 'therealsatoshi',
|
||||
wiki_username: 'Satoshi',
|
||||
url: undefined,
|
||||
ipfsData: json,
|
||||
};
|
||||
assert.deepEqual(expected, deserialized);
|
||||
});
|
||||
let deserialized = ContributorSerializer.deserialize(json);
|
||||
|
||||
let expected = {
|
||||
name: 'Satoshi Nakamoto',
|
||||
kind: 'person',
|
||||
github_uid: 123,
|
||||
github_username: 'therealsatoshi',
|
||||
wiki_username: 'Satoshi',
|
||||
url: undefined,
|
||||
ipfsData: json,
|
||||
};
|
||||
assert.deepEqual(expected, deserialized);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
moduleFor('model:contributor', 'Unit | Model | contributor');
|
||||
import { run } from '@ember/runloop';
|
||||
|
||||
test('#avatarURL() returns correct URL', function(assert) {
|
||||
let model = this.subject();
|
||||
model.set('github_uid', '318');
|
||||
module('Unit | Model | contributor', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
assert.equal(model.get('avatarURL'), 'https://avatars2.githubusercontent.com/u/318?v=3&s=128');
|
||||
test('#avatarURL() returns correct URL', function(assert) {
|
||||
let model = run(() => this.owner.lookup('service:store').createRecord('contributor'));
|
||||
model.set('github_uid', '318');
|
||||
|
||||
assert.equal(model.get('avatarURL'), 'https://avatars2.githubusercontent.com/u/318?v=3&s=128');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:application', 'Unit | Route | application', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
module('Unit | Route | application', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.subject();
|
||||
assert.ok(route);
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:application');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:spinner', 'Unit | Route | spinner', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
module('Unit | Route | spinner', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.subject();
|
||||
assert.ok(route);
|
||||
test('it exists', function(assert) {
|
||||
let route = this.owner.lookup('route:spinner');
|
||||
assert.ok(route);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:kredits', 'Unit | Service | kredits', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['service:foo']
|
||||
});
|
||||
module('Unit | Service | kredits', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let service = this.subject();
|
||||
assert.ok(service);
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let service = this.owner.lookup('service:kredits');
|
||||
assert.ok(service);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user