21
21
// MODULES //
22
22
23
23
var tape = require ( 'tape' ) ;
24
- var isMethod = require ( '@stdlib/assert/is-method' ) ;
24
+ var proxyquire = require ( 'proxyquire' ) ;
25
+ var IS_BROWSER = require ( '@stdlib/assert/is-browser' ) ;
25
26
var dladiv = require ( './../lib' ) ;
26
27
27
28
29
+ // VARIABLES //
30
+
31
+ var opts = {
32
+ 'skip' : IS_BROWSER
33
+ } ;
34
+
35
+
28
36
// TESTS //
29
37
30
38
tape ( 'main export is a function' , function test ( t ) {
@@ -33,14 +41,42 @@ tape( 'main export is a function', function test( t ) {
33
41
t . end ( ) ;
34
42
} ) ;
35
43
36
- tape ( 'attached to the main export is an `assign` method' , function test ( t ) {
37
- t . ok ( true , __filename ) ;
38
- t . strictEqual ( isMethod ( dladiv , 'assign' ) , true , 'returns expected value' ) ;
44
+ tape ( 'attached to the main export is a method providing an ndarray interface' , function test ( t ) {
45
+ t . strictEqual ( typeof dladiv . ndarray , 'function' , 'method is a function' ) ;
39
46
t . end ( ) ;
40
47
} ) ;
41
48
42
- tape ( 'attached to the main export is a `strided` method' , function test ( t ) {
43
- t . ok ( true , __filename ) ;
44
- t . strictEqual ( isMethod ( dladiv , 'strided' ) , true , 'returns expected value' ) ;
49
+ tape ( 'if a native implementation is available, the main export is the native implementation' , opts , function test ( t ) {
50
+ var dladiv = proxyquire ( './../lib' , {
51
+ '@stdlib/utils/try-require' : tryRequire
52
+ } ) ;
53
+
54
+ t . strictEqual ( dladiv , mock , 'returns expected value' ) ;
45
55
t . end ( ) ;
56
+
57
+ function tryRequire ( ) {
58
+ return mock ;
59
+ }
60
+
61
+ function mock ( ) {
62
+ // Mock...
63
+ }
64
+ } ) ;
65
+
66
+ tape ( 'if a native implementation is not available, the main export is a JavaScript implementation' , opts , function test ( t ) {
67
+ var dladiv ;
68
+ var main ;
69
+
70
+ main = require ( './../lib/dladiv.js' ) ;
71
+
72
+ dladiv = proxyquire ( './../lib' , {
73
+ '@stdlib/utils/try-require' : tryRequire
74
+ } ) ;
75
+
76
+ t . strictEqual ( dladiv , main , 'returns expected value' ) ;
77
+ t . end ( ) ;
78
+
79
+ function tryRequire ( ) {
80
+ return new Error ( 'Cannot find module' ) ;
81
+ }
46
82
} ) ;
0 commit comments