Demo for query storing

Change-Id: I947bcac841992c3f6cfd01ab337c265b0d01cb70
diff --git a/node_modules/css-select-base-adapter/test/data.js b/node_modules/css-select-base-adapter/test/data.js
new file mode 100644
index 0000000..c16dfd6
--- /dev/null
+++ b/node_modules/css-select-base-adapter/test/data.js
@@ -0,0 +1,34 @@
+'use strict'
+
+const walk = ( node, parent, cb ) => {
+  cb( node, parent )
+
+  if( Array.isArray( node.children ) )
+    node.children.forEach( child => walk( child, node, cb ) )
+}
+
+const data = {
+  name: 'div',
+  attribs: {
+    id: 'container',
+    class: 'message'
+  },
+  children: [
+    {
+      name: 'strong',
+      attribs: {
+        class: 'message'
+      },
+      children: [
+        { text: 'Hello' }
+      ]
+    },
+    { text: ', World!' }
+  ]
+}
+
+walk( data, null, ( node, parent ) => {
+  if( parent ) node.parent = parent
+})
+
+module.exports = [ data ]
diff --git a/node_modules/css-select-base-adapter/test/implementation.js b/node_modules/css-select-base-adapter/test/implementation.js
new file mode 100644
index 0000000..c88985b
--- /dev/null
+++ b/node_modules/css-select-base-adapter/test/implementation.js
@@ -0,0 +1,22 @@
+'use strict'
+
+const implementation = {
+  isTag: node => node !== undefined && 'name' in node,
+  getAttributeValue: ( elem, name ) => {
+    if( implementation.isTag( elem ) && elem.attribs ) return elem.attribs[ name ]
+  },
+  getChildren: node => node.children,
+  getName: elem => {
+    if( implementation.isTag( elem ) ) return elem.name
+  },
+  getParent: node => node.parent,
+  getText: node => node.children.map( child => {
+    if( child.text ) return child.text
+
+    if( implementation.isTag( child ) ) return implementation.getText( child )
+
+    return ''
+  }).join( '' )
+}
+
+module.exports = implementation
diff --git a/node_modules/css-select-base-adapter/test/index.js b/node_modules/css-select-base-adapter/test/index.js
new file mode 100644
index 0000000..fc73b3e
--- /dev/null
+++ b/node_modules/css-select-base-adapter/test/index.js
@@ -0,0 +1,103 @@
+'use strict'
+
+const assert = require( 'assert' )
+const data = require( './data' )
+const implementation = require( './implementation' )
+const baseAdapter = require( '../' )
+
+const adapter = baseAdapter( implementation )
+
+const getById = id => adapter.findOne( 
+  node => adapter.getAttributeValue( node, 'id' ) === id,
+  data 
+) 
+
+const getByName = name => adapter.findAll( 
+  node => adapter.getName( node ) === name,
+  data 
+)
+
+const getByClass = className => adapter.findAll( 
+  node => adapter.getAttributeValue( node, 'class' ) === className,
+  data 
+) 
+
+const existsName = name => adapter.existsOne(
+  node => adapter.getName( node ) === name,
+  data
+)
+
+const container = getById( 'container' ) 
+const strong = getByName( 'strong' )[ 0 ]
+const hello = strong.children[ 0 ]
+const world = container.children[ 1 ]
+
+describe( 'css-select-base-adapter', () => {
+  it( 'getAttributeValue', () => {
+    assert( container )
+  })
+
+  it( 'getName', () => {
+    assert( strong )
+  })
+
+  it( 'findOne', () => {
+    assert( container )
+  })
+
+  it( 'findAll', () => {
+    const messages = getByClass( 'message' )
+    
+    assert.equal( messages.length, 2 )
+    assert.equal( messages[ 0 ], container )
+    assert.equal( messages[ 1 ], strong )
+  })
+
+  it( 'getParent', () => {
+    const parent = adapter.getParent( strong )
+
+    assert.equal( parent, container )
+  })
+
+  it( 'getSiblings', () => {
+    const siblings = adapter.getSiblings( strong )
+
+    assert.equal( siblings[ 0 ], strong )
+    assert.equal( siblings[ 1 ], world )
+  })
+
+  it( 'getChildren', () => {
+    const children = adapter.getChildren( container )
+
+    assert.equal( children[ 0 ], strong )
+  })
+
+  it( 'getText', () => {
+    const text = adapter.getText( container )
+
+    assert.equal( text, 'Hello, World!' )
+  })
+
+  it( 'isTag', () => {
+    assert( adapter.isTag( container ) )
+    assert( adapter.isTag( strong ) )
+    assert( !adapter.isTag( hello ) )
+  })
+
+  it( 'hasAttrib', () => {
+    assert( adapter.hasAttrib( container, 'id' ) )
+    assert( !adapter.hasAttrib( strong, 'id' ) )
+  })
+
+  it( 'existsOne', () => {
+    assert( existsName( 'strong' ) )
+    assert( !existsName( 'blink' ) )
+  })
+
+  it( 'removeSubsets', () => {
+    const removed = adapter.removeSubsets([ container, strong, container ])
+
+    assert.equal( removed.length, 1 )
+    assert.equal( removed[ 0 ], container )
+  })
+})