-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[image-url] Allow using actual query parameters instead of aliases (#792
- Loading branch information
Showing
8 changed files
with
122 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,20 +5,20 @@ | |
"main": "index.js", | ||
"scripts": { | ||
"build": "npm run clean && npm run compile", | ||
"coverage": "jest --coverage", | ||
"compile": "babel --source-maps --copy-files -d lib/ src/", | ||
"clean": "rimraf lib", | ||
"postpublish": "npm run clean", | ||
"test": "mocha --recursive --require babel-register test" | ||
"test": "jest" | ||
}, | ||
"author": "Sanity.io <[email protected]>", | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^5.0.1", | ||
"rimraf": "^2.6.2", | ||
"should": "^11.1.0" | ||
"jest": "^22.4.3", | ||
"rimraf": "^2.6.2" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"env": { | ||
"mocha": true | ||
"jest": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
import should from 'should' | ||
import {parseSource} from '../src/urlForImage' | ||
import {imageWithNoCropSpecified, croppedImage} from './fixtures' | ||
|
||
function compareParsedSource(outputSource, exptectedSource) { | ||
should(outputSource).be.an.Object() | ||
should(outputSource.asset).be.an.Object() | ||
should(outputSource.asset._ref).be.eql(exptectedSource.asset._ref) | ||
should(outputSource).have.keys('crop', 'hotspot') | ||
expect(typeof outputSource).toBe('object') | ||
expect(typeof outputSource.asset).toBe('object') | ||
expect(outputSource.asset._ref).toEqual(exptectedSource.asset._ref) | ||
expect(outputSource).toHaveProperty('crop') | ||
expect(outputSource).toHaveProperty('hotspot') | ||
} | ||
|
||
describe('parseSource', () => { | ||
it('does correctly parse full image object', () => { | ||
test('does correctly parse full image object', () => { | ||
const parsedSource = parseSource(imageWithNoCropSpecified()) | ||
compareParsedSource(parsedSource, imageWithNoCropSpecified()) | ||
}) | ||
|
||
it('does correctly parse asset object', () => { | ||
test('does correctly parse asset object', () => { | ||
const parsedSource = parseSource(imageWithNoCropSpecified().asset._ref) | ||
compareParsedSource(parsedSource, imageWithNoCropSpecified()) | ||
}) | ||
|
||
it('does correctly parse image asset _ref', () => { | ||
test('does correctly parse image asset _ref', () => { | ||
const parsedSource = parseSource(imageWithNoCropSpecified().asset) | ||
compareParsedSource(parsedSource, imageWithNoCropSpecified()) | ||
}) | ||
|
||
it('does not overwrite cropp or hotspot settings', () => { | ||
should(parseSource(croppedImage())).deepEqual(croppedImage()) | ||
test('does not overwrite crop or hotspot settings', () => { | ||
expect(parseSource(croppedImage())).toEqual(croppedImage()) | ||
}) | ||
|
||
test('returns null on non-image object', () => { | ||
expect(parseSource({})).toEqual(null) | ||
}) | ||
}) |
Oops, something went wrong.