Skip to content

Commit

Permalink
Push test sources into test/src
Browse files Browse the repository at this point in the history
  • Loading branch information
Burt Harris authored and Burt Harris committed Jul 28, 2017
1 parent 10b7b78 commit 4ae646f
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 52 deletions.
2 changes: 1 addition & 1 deletion test/exports.spec.js → test/src/exports.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from 'path';
import * as glob from 'glob';
const camelCase = require('camelCase')
const interopRequire = require('interop-require');
import * as decorators from '../';
import * as decorators from 'core-decorators';

const should = chai.should();

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import applyDecorators from '../../lib/applyDecorators';
import autobind from '../../lib/autobind';
import readonly from '../../lib/readonly';
import enumerable from '../../lib/enumerable';
// @ts-nocheck
import {applyDecorators, autobind, readonly, enumerable} from 'core-decorators';

describe('applyDecorators() helper', function () {
class Foo {
Expand Down
44 changes: 23 additions & 21 deletions test/unit/autobind.spec.js → test/src/unit/autobind.spec.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import { expect } from 'chai';
import autobind from '../../lib/autobind';
import { autobind } from 'core-decorators';

const root = (typeof window !== 'undefined') ? window : global;

describe('@autobind', function () {
let Foo;
let Bar;
let Car;
let barCount;

beforeEach(function () {
Foo = class Foo {
class Foo {
@autobind
getFoo() {
return this;
}

getFooAgain() {
return this;
return this;
}

@autobind
Expand All @@ -26,10 +20,9 @@ describe('@autobind', function () {
}
}

barCount = 0;

Bar = class Bar extends Foo {
@autobind()
class Bar extends Foo {
// @ts-ignore
@autobind()
getFoo() {
const foo = super.getFoo();
barCount++;
Expand All @@ -49,18 +42,22 @@ describe('@autobind', function () {
return this;
}
}

Car = class Car extends Foo {

class Car extends Foo {
// @ts-ignore
@autobind()
getCarFromFoo() {
return super.onlyOnFoo();
}
}

let barCount = 0;

beforeEach(function () {
barCount = 0;
});

afterEach(function () {
Foo = null;
Bar = null;
barCount = null;
});

Expand Down Expand Up @@ -93,13 +90,14 @@ describe('@autobind', function () {
it('sets the correct instance descriptor options when reassigned outside', function () {
const noop = function () {};
const foo = new Foo();
// @ts-ignore
const ret = foo.getFoo = noop;
const desc = Object.getOwnPropertyDescriptor(foo, 'getFoo');

ret.should.equal(noop);
desc.configurable.should.equal(true);
desc.enumerable.should.equal(true);
desc.writable.should.equal(true);
desc.configurable.should.equal(true, "configurable");
desc.enumerable.should.equal(true, "enumerable");
desc.writable.should.equal(true, "writable");
desc.value.should.equal(noop);
});

Expand Down Expand Up @@ -151,7 +149,9 @@ describe('@autobind', function () {
});

it('throws when it needs WeakMap but it is not available', function () {
// @ts-ignore
const WeakMap = root.WeakMap;
// @ts-ignore
delete root.WeakMap;

const bar = new Bar();
Expand All @@ -163,6 +163,7 @@ describe('@autobind', function () {

barCount.should.equal(0);

// @ts-ignore
root.WeakMap = WeakMap;
});

Expand Down Expand Up @@ -201,7 +202,7 @@ describe('@autobind', function () {
}

@autobind
class Car extends Vehicle {
class Car extends Vehicle {
constructor() {
super();
this.name = 'amazing';
Expand Down Expand Up @@ -249,6 +250,7 @@ describe('@autobind', function () {
@autobind
class A {
method() {
// @ts-ignore
return this.test || 'WRONG ONE';
}
}
Expand Down
19 changes: 9 additions & 10 deletions test/unit/decorate.spec.js → test/src/unit/decorate.spec.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import decorate from '../../lib/decorate';
import { decorate } from 'core-decorators';
import { memoize } from 'lodash';

describe('@decorate', function () {
let Foo;
let callCount;

beforeEach(function () {
const append = function (fn, suffix) {
function append (fn, suffix) {
return function (msg) {
return fn.call(this, msg) + suffix;
};
};

callCount = 0;

Foo = class Foo {

class Foo {
@decorate(append, '!')
suchWow(something) {
return something + 'bro';
Expand All @@ -39,6 +33,11 @@ describe('@decorate', function () {
return this;
}
}

let callCount;

beforeEach(function () {
callCount = 0;
});

it('correctly applies user provided function to method', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sinon from 'sinon';
import deprecate from '../../lib/deprecate';
import * as utils from '../../lib/private/utils';
import { deprecate } from 'core-decorators';
import * as utils from 'core-decorators/lib/private/utils';

class Foo {
@deprecate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import enumerable from '../../lib/enumerable';
import { enumerable } from 'core-decorators';

describe('@enumerable', function () {
class Foo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import extendDescriptor from '../../lib/extendDescriptor';
import enumerable from '../../lib/enumerable';
import nonenumerable from '../../lib/nonenumerable';
import {enumerable, nonenumerable} from 'core-decorators';
import {extendDescriptor} from 'core-decorators/lib/extendDescriptor';

describe('@extendDescriptor', function () {
class Base {
get first() {
// @ts-ignore
return this._first;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { spy } from 'sinon';
import lazyInitialize from '../../lib/lazy-initialize';
import {lazyInitialize} from 'core-decorators';

describe('@lazyInitialize', function () {
let initializer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import nonconfigurable from '../../lib/nonconfigurable';
import readonly from '../../lib/readonly';
import {nonconfigurable, readonly} from 'core-decorators';

describe('@nonconfigurable', function () {
class Foo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import nonenumerable from '../../lib/nonenumerable';
import { nonenumerable } from 'core-decorators';

describe('@nonenumerable', function () {
class Foo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import override from '../../lib/override';
import { override } from 'core-decorators';

class Parent {
speak(first, second) {}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/profile.spec.js → test/src/unit/profile.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { spy, useFakeTimers } from 'sinon';
import applyDecorators from '../../lib/applyDecorators';
import profile, { defaultConsole } from '../../lib/profile';
import { applyDecorators, profile, defaultConsole } from 'core-decorators';

const CONSOLE_PROFILE = defaultConsole.profile;
const CONSOLE_PROFILEEND = defaultConsole.profileEnd;
Expand Down Expand Up @@ -198,6 +197,7 @@ describe('@profile', function() {
profileSpy.calledOnce.should.equal(false);
cbSpy.calledOnce.should.equal(true);

// @ts-ignore
foo.isAwesome = true;

foo.profileFunctioned(cbSpy);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import readonly from '../../lib/readonly';
import { readonly } from 'core-decorators';

describe('@readonly', function () {
class Foo {
Expand All @@ -18,6 +18,7 @@ describe('@readonly', function () {
const foo = new Foo();

(function () {
// @ts-ignore
foo.first = 'I will error';
}).should.throw('Cannot assign to read only property \'first\' of object \'#<Foo>\'');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spy } from 'sinon';
import suppressWarnings from '../../lib/suppress-warnings';
import { suppressWarnings } from 'core-decorators';

const CONSOLE_WARN = console.warn;

Expand Down
2 changes: 1 addition & 1 deletion test/unit/time.spec.js → test/src/unit/time.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spy } from 'sinon';
import time, { defaultConsole } from '../../lib/time';
import { time, defaultConsole } from 'core-decorators';

const CONSOLE_TIME = defaultConsole.time;
const CONSOLE_TIMEEND = defaultConsole.timeEnd;
Expand Down

0 comments on commit 4ae646f

Please sign in to comment.