Comments (16)
from node-pureimage.
Cool - I've had a look at using jest
in the place of tape
. Reason being is that (in my opinion) it produces better readable test output, it supports mocking and it's easier to configure (pretty much no config out of the box).
The syntax looks like this:
const Point = require('../../src/Point');
const Line = require('../../src/Line');
describe('Line', () => {
it('created from two points use them as start and end points', () => {
let start = new Point(6, 8);
let end = new Point(12, 6);
expect(() => new Line(start, end)).not.toThrow(TypeError);
expect(() => new Line(6, 8)).toThrow();
});
it('created from 4 ordinates uses them as start and end points', () => {
expect(() => new Line(6, 8, 12, 6)).not.toThrow();
expect(() => new Line({}, "spaghetti", "hello world", [])).toThrow(TypeError);
});
it('can only be created with either 2 or 4 arguments', () => {
let errorMsg = 'Please pass either two Point objects, or 4 integers to the constructor';
expect(() => new Line()).toThrow(errorMsg);
expect(() => new Line(12)).toThrow(errorMsg);
expect(() => new Line(12, 30, 92)).toThrow(errorMsg);
expect(() => new Line(12, 30, 92, 10, 99)).toThrow(errorMsg);
});
it('is the distance between two points', () => {
let start = new Point(6, 8);
let end = new Point(0, 0);
let line = new Line(start, end);
expect(line.getLength()).toBe(10);
})
});
Which produces output that looks like this:
from node-pureimage.
Forgot to mention - it also supports mocking too, which might be nice when dealing with dependencies between objects like Context
and Bitmap
from node-pureimage.
@joshmarinacci - I'm just busy converting some of the existing tests into unit tests...I was wondering what this did:
var PImage = require('../src/pureimage');
{
// compositing tests
// red onto white
eq(PImage.compositePixel(0xFF0000FF, 0xFFFFFFFF), 0xFF0000FF);
// blue onto white
eq(PImage.compositePixel(0x00FF00FF, 0xFFFFFFFF), 0x00FF00FF);
// red onto black
eq(PImage.compositePixel(0xFF0000FF, 0x000000FF), 0xFF0000FF);
// red 50% onto black
eq(PImage.compositePixel(0xFF00007F, 0x000000FF), 0x7F0000FF);
}
function eq(a,b) {
if(a != b) throw new Error(a.toString(16) + " is not equal to " + b.toString(16));
}
function dumpBytes(img) {
for(var i=0; i<10; i++) {
console.log(i,img._buffer[i].toString(16));
}
}
It's clearly testing the compositePixel
method - but I'm not quite sure what that method does - I also can't seem to find it in the library anywhere...unless it's referring to the composite
method in the Bitmap
class?
from node-pureimage.
from node-pureimage.
OK, no problem. In the mean time if you have a sec - #42 and #39 are done and ready for review/merge :)
from node-pureimage.
from node-pureimage.
haha, no problem - i know how it is :)
not a problem - always happy to help out :D
from node-pureimage.
Oh by the way - I just looked at https://travis-ci.org/joshmarinacci/node-pureimage and it says it's not an active repo. Have you enabled travis because it looks like it's not running the build
from node-pureimage.
from node-pureimage.
Looks like you're missing the GITHUB_TOKEN
environment var from Travis. Take a look at the pre-requisites here: #39 (comment) :)
Also - you might want to consider adding a link to http://joshmarinacci.github.io/node-pureimage
at the top of your README for the documentation :)
Also - travis should let you rerun the failed build
from node-pureimage.
from node-pureimage.
Odd - I took a look and it's mentioning that it couldn't push to gh-pages
. It looks like it was saying that it couldn't push to Couldn't push the build to github.com/joshmarinacci/node-pureimage.git:gh-pages
. I wonder if maybe the branch didn't exist at that point or something.
Try re-running the individual job again - if that still doesn't do it, you may have to raise an issue with Travis. Either way - looks like the docs are online! http://joshmarinacci.github.io/node-pureimage
from node-pureimage.
This looks like it might be related to travis-ci/travis-ci#8548
from node-pureimage.
I emailed Travis support yesterday and they wondered if it might be because all 3 jobs are trying to do the deploy...can you try adding node: $TRAVIS_NODE_VERSION
after line 18 of .travis.yml?
Like so:
language: node_js
node_js:
- "node"
- "7"
- "8"
install: npm install
script:
- npm run-script docs
deploy:
overwrite: true
provider: pages
file_glob: true
file: docs/*
local_dir: docs
skip_cleanup: true
github_token: $GITHUB_TOKEN
on:
branch: master
node: $TRAVIS_NODE_VERSION
This should restrict it so that only one build job actually deploys
from node-pureimage.
it looks like all of this was done.
from node-pureimage.
Related Issues (20)
- context.font TypeScript types declaration are wrong. HOT 4
- on 'error' is registered 2 times
- work in cloudflare workers HOT 7
- Error: SOI not found
- Rendered path rounding some lines? HOT 1
- fillText produces odd results with some fonts HOT 7
- how to embed the image which i have just created with the message? HOT 5
- ctx.restore() doesn't appear to clear clipping region. HOT 4
- support reading large files HOT 3
- transforms not taking effect for fillRect and drawImage? HOT 7
- drawImage. RangeError: Maximum call stack size exceeded HOT 2
- pngjs outdated causing deprecation warning HOT 1
- [feature] createConicGradient missing
- Path is distorted
- Please support lineCap
- Transparent background HOT 2
- Create a virtual Canvas (without `canvas#data` object)
- Image transparency overwrites existing content
- Error: export 'make' (imported as 'PImage') was not found in 'pureimage' (module has no exports) HOT 7
- [feature request] setting the encode option (e.g. PNG compression level) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-pureimage.