File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 1
1
class BmwFactory {
2
2
3
- create ( type ) {
3
+ static create ( type ) {
4
4
if ( type === 'X5' )
5
5
return new Bmw ( type , 108000 , 300 ) ;
6
6
if ( type === 'X6' )
Original file line number Diff line number Diff line change 1
1
const expect = require ( 'chai' ) . expect ;
2
2
import BmwFactory from '../src/creational/factory/factory_es6' ;
3
3
4
- describe ( 'factory es6 test' , ( ) => {
5
- it ( 'sanity ' , ( ) => {
6
- const bmwFactory = new BmwFactory ( ) ;
7
- const x5 = bmwFactory . create ( 'X5' ) ;
8
- const x6 = bmwFactory . create ( 'X6' ) ;
4
+ describe ( 'Factory es6 test' , ( ) => {
5
+ it ( 'We can create a X5 instance ' , ( ) => {
6
+ const x5 = BmwFactory . create ( 'X5' ) ;
7
+ expect ( x5 . model ) . to . equal ( 'X5' ) ;
8
+ } ) ;
9
9
10
+ it ( 'The X5 price is properly set' , ( ) => {
11
+ const x5 = BmwFactory . create ( 'X5' ) ;
10
12
expect ( x5 . price ) . to . equal ( 108000 ) ;
11
- expect ( x6 . price ) . to . equal ( 111000 ) ;
12
- expect ( x5 . maxSpeed ) . to . equal ( 300 ) ;
13
- expect ( x6 . maxSpeed ) . to . equal ( 320 ) ;
14
13
} ) ;
15
14
} ) ;
You can’t perform that action at this time.
0 commit comments