forked from jsmapr1/simplifying-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget.spec.js
More file actions
64 lines (54 loc) · 1.59 KB
/
Copy pathget.spec.js
File metadata and controls
64 lines (54 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import expect from 'expect';
import Coupon from './get';
import CouponProblem from './problem';
import CouponGetters from './price';
import CouponSet from './set';
describe('get problem', () => {
it('should set price as a string', () => {
const coupon = new CouponProblem(5);
coupon.price = '$10';
expect(coupon.getPriceText()).toEqual('$ $10');
});
});
describe('Getters', () => {
const coupon = new CouponGetters(10);
it('should get price text', () => {
expect(coupon.priceText).toEqual('$ 10');
});
it('should get expiration text', () => {
const message = 'This offer expires in two weeks.';
expect(coupon.expirationMessage).toEqual(message);
});
});
describe('Setters', () => {
const coupon = new CouponSet(10);
it('should get price', () => {
expect(coupon.price).toEqual(10);
});
it('should set halfPrice', () => {
coupon.halfPrice = 40;
expect(coupon.price).toEqual(20);
});
});
describe('getters and setters', () => {
it('should get a inner variable', () => {
const coupon = new Coupon(10);
expect(coupon.price).toEqual(coupon._price);
});
it('should set inner property', () => {
const coupon = new Coupon(10);
expect(coupon.price).toEqual(10);
coupon.price = 100;
expect(coupon.price).toEqual(100);
});
it('should parse int when setting', () => {
const coupon = new Coupon(10);
expect(coupon.price).toEqual(10);
coupon.price = '$100';
expect(coupon.price).toEqual(100);
});
it('should get a message', () => {
const coupon = new Coupon(10);
expect(coupon.priceText).toEqual('$10');
});
});