Skip to content
This repository was archived by the owner on Feb 4, 2018. It is now read-only.

Commit 3d3a0a8

Browse files
author
blond
committed
test(deprecation): add deprecate util
1 parent 3d2ea28 commit 3d3a0a8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/deprecate.test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const test = require('ava');
2+
const sinon = require('sinon');
3+
const proxyquire = require('proxyquire');
4+
5+
const BemEntityName = require('../lib/entity-name');
6+
7+
const deprecateSpy = sinon.spy();
8+
const deprecate = proxyquire('../lib/deprecate', {
9+
'depd':() => deprecateSpy
10+
});
11+
12+
test('should deprecate object', t => {
13+
deprecate({ block: 'block' }, 'oldField', 'newField');
14+
15+
const message = [
16+
"`oldField` is kept just for compatibility and can be dropped in the future.",
17+
"Use `newField` instead in `{ block: 'block' }` at"
18+
].join(' ');
19+
20+
t.true(deprecateSpy.calledWith(message));
21+
});
22+
23+
test('should deprecate BemEntityName instance', t => {
24+
deprecate(new BemEntityName({ block: 'block' }), 'oldField', 'newField');
25+
26+
const message = [
27+
"`oldField` is kept just for compatibility and can be dropped in the future.",
28+
"Use `newField` instead in `BemEntityName { block: 'block' }` at"
29+
].join(' ');
30+
31+
t.true(deprecateSpy.calledWith(message));
32+
});

0 commit comments

Comments
 (0)