File tree Expand file tree Collapse file tree 4 files changed +74
-0
lines changed
Expand file tree Collapse file tree 4 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 2828 "babel-preset-es2015" : " ^6.14.0" ,
2929 "babel-preset-react" : " ^6.11.1" ,
3030 "babel-preset-stage-1" : " ^6.13.0" ,
31+ "chai" : " ^3.5.0" ,
32+ "enzyme" : " ^2.4.1" ,
33+ "mocha" : " ^3.0.2" ,
3134 "react" : " ^15.3.1" ,
35+ "react-addons-test-utils" : " ^15.3.1" ,
3236 "react-dom" : " ^15.3.1" ,
3337 "webpack" : " ^1.13.2"
3438 },
Original file line number Diff line number Diff line change 1+ require ( 'babel-register' ) ( ) ;
2+
3+ var jsdom = require ( 'jsdom' ) . jsdom ;
4+
5+ var exposedProperties = [ 'window' , 'navigator' , 'document' ] ;
6+
7+ global . document = jsdom ( '' ) ;
8+ global . window = document . defaultView ;
9+ Object . keys ( document . defaultView ) . forEach ( ( property ) => {
10+ if ( typeof global [ property ] === 'undefined' ) {
11+ exposedProperties . push ( property ) ;
12+ global [ property ] = document . defaultView [ property ] ;
13+ }
14+ } ) ;
15+
16+ global . navigator = {
17+ userAgent : 'node.js'
18+ } ;
19+
20+ documentRef = document ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { expect } from 'chai' ;
3+ import { shallow , mount , render } from 'enzyme' ;
4+ import Image from '../src/components/Image' ;
5+
6+ describe ( 'Image' , ( ) => {
7+ beforeEach ( ( ) => {
8+ } ) ;
9+ it ( "should create an img tag" , function ( ) {
10+ let tag = shallow ( < Image publicId = "sample" cloudName = "demo" /> ) ;
11+ expect ( tag . type ( ) ) . to . equal ( "img" ) ;
12+ expect ( tag . state ( "url" ) ) . to . equal ( "http://res.cloudinary.com/demo/image/upload/sample" ) ;
13+ } ) ;
14+ it ( "should allow transformation params as attributes" , function ( ) {
15+ let width = 300 ;
16+ let tag = shallow ( < Image publicId = "sample" cloudName = "demo" width = { width } crop = "scale" /> ) ;
17+ expect ( tag . type ( ) ) . to . equal ( "img" ) ;
18+ expect ( tag . state ( "url" ) ) . to . equal ( "http://res.cloudinary.com/demo/image/upload/c_scale,w_300/sample" ) ;
19+ } ) ;
20+ } ) ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { expect } from 'chai' ;
3+ import { shallow , mount , render } from 'enzyme' ;
4+ import Image from '../src/components/Image' ;
5+ import Transformation from '../src/components/Transformation' ;
6+
7+
8+ describe ( 'Transformation' , ( ) => {
9+ beforeEach ( ( ) => {
10+ } ) ;
11+ it ( "should create an img tag" , function ( ) {
12+ let tag = shallow (
13+ < Image publicId = "sample" cloudName = "demo" >
14+ < Transformation width = "100" crop = "scale" angle = "10" />
15+ </ Image >
16+ ) ;
17+ expect ( tag . name ( ) ) . to . equal ( "img" ) ;
18+ expect ( tag . state ( "url" ) ) . to . equal ( "http://res.cloudinary.com/demo/image/upload/a_10,c_scale,w_100/sample" ) ;
19+ } ) ;
20+ it ( "should allow chained transformations" , function ( ) {
21+ let tag = shallow (
22+ < Image publicId = "sample" cloudName = "demo" >
23+ < Transformation width = "100" crop = "scale" />
24+ < Transformation width = "200" crop = "crop" />
25+ </ Image >
26+ ) ;
27+ expect ( tag . type ( ) ) . to . equal ( "img" ) ;
28+ expect ( tag . state ( "url" ) ) . to . equal ( "http://res.cloudinary.com/demo/image/upload/c_scale,w_100/c_crop,w_200/sample" ) ;
29+ } ) ;
30+ } ) ;
You can’t perform that action at this time.
0 commit comments