initial commit
This commit is contained in:
21
node_modules/region/test/RegionEqualityTests.js
generated
vendored
Normal file
21
node_modules/region/test/RegionEqualityTests.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
describe('Region equal', function(){
|
||||
|
||||
var Region = require('../index')
|
||||
|
||||
it('size should return fine', function(){
|
||||
|
||||
var r = Region({
|
||||
top : 10,
|
||||
left : 10,
|
||||
width : 10,
|
||||
height: 10
|
||||
})
|
||||
|
||||
r.equalsSize({
|
||||
width : 10,
|
||||
height: 10
|
||||
})
|
||||
.should
|
||||
.equal(true)
|
||||
})
|
||||
})
|
||||
18
node_modules/region/test/RegionIntersection.js
generated
vendored
Normal file
18
node_modules/region/test/RegionIntersection.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
describe('Region intersection', function(){
|
||||
|
||||
var Region = require('../index')
|
||||
|
||||
it('should containPoint', function(){
|
||||
var inner = Region({
|
||||
left: 97, right: 147, top: 51, bottom: 251
|
||||
})
|
||||
|
||||
var outer = Region({
|
||||
left: 11, right: 447, top: 51, bottom: 937
|
||||
})
|
||||
|
||||
outer.getIntersection(inner).getArea()
|
||||
.should
|
||||
.equal(inner.getArea())
|
||||
})
|
||||
})
|
||||
25
node_modules/region/test/RegionPointTests.js
generated
vendored
Normal file
25
node_modules/region/test/RegionPointTests.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
describe('Region point functions', function(){
|
||||
|
||||
var Region = require('../index')
|
||||
|
||||
it('should containPoint', function(){
|
||||
var r = Region({
|
||||
top: 10,
|
||||
left: 10,
|
||||
width: 10,
|
||||
height: 10
|
||||
})
|
||||
|
||||
r.containsPoint(15, 10)
|
||||
.should
|
||||
.equal(true)
|
||||
|
||||
r.containsPoint({x: 10, y: 10})
|
||||
.should
|
||||
.equal(true)
|
||||
|
||||
r.containsPoint(25, 10)
|
||||
.should
|
||||
.equal(false)
|
||||
})
|
||||
})
|
||||
57
node_modules/region/test/RegionTests.js
generated
vendored
Normal file
57
node_modules/region/test/RegionTests.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
describe('Region', function(){
|
||||
var Region = require('../index')
|
||||
|
||||
it('should have correct width', function(){
|
||||
var r = Region({
|
||||
top: 10,
|
||||
left: 20,
|
||||
right: 40,
|
||||
bottom: 20
|
||||
})
|
||||
|
||||
r.getWidth()
|
||||
.should
|
||||
.equal(20)
|
||||
|
||||
})
|
||||
|
||||
it('should have correct height', function(){
|
||||
var r = new Region({
|
||||
top: 10,
|
||||
left: 20,
|
||||
width: 30,
|
||||
height: 40
|
||||
})
|
||||
|
||||
r.getBottom()
|
||||
.should
|
||||
.equal(50)
|
||||
})
|
||||
|
||||
it('should return correct intersection', function(){
|
||||
var r1 = Region({
|
||||
top: 10,
|
||||
left: 10,
|
||||
right: 40,
|
||||
bottom: 40
|
||||
})
|
||||
|
||||
var r2 = Region({
|
||||
top: 20,
|
||||
left: 15,
|
||||
right: 45,
|
||||
bottom: 35
|
||||
})
|
||||
|
||||
var intersection = r1.getIntersection(r2)
|
||||
|
||||
intersection.get()
|
||||
.should
|
||||
.eql({
|
||||
top: 20,
|
||||
left: 15,
|
||||
right: 40,
|
||||
bottom: 35
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user